const data = [
    {
        "id": "1175310929766055936",
        "pid": "",
        "companyId": "1",
        "name": "总裁办",
        "code": "ZCB",
        "managerId": null,
        "manager": "孙财",
        "introduce": "总裁办公室",
        "createTime": null,
    },
    {
        "id": "1175311213774962688",
        "pid": "",
        "companyId": "1",
        "name": "行政部",
        "code": "XZB",
        "managerId": null,
        "manager": "罗晓晓",
        "introduce": "1111",
        "createTime": null
    },
    {
        "id": "1175311267684352000",
        "pid": "",
        "companyId": "1",
        "name": "人事部",
        "code": "RSB",
        "managerId": "1071632760222810112",
        "manager": "文吉星",
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1175311325720936448",
        "pid": "",
        "companyId": "1",
        "name": "财务部",
        "code": "",
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1175311373083017216",
        "pid": "",
        "companyId": "1",
        "name": "技术部",
        "code": "JSB",
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1175311418004013056",
        "pid": "",
        "companyId": "1",
        "name": "运营部",
        "code": "YYB",
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1175311466846683136",
        "pid": "",
        "companyId": "1",
        "name": "市场部",
        "code": "SCB",
        "managerId": "1063705989926227968",
        "manager": "武高丽",
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235395178363559936",
        "pid": "1175311325720936448",
        "companyId": "1",
        "name": "财务核算部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398264104624128",
        "pid": "1175311325720936448",
        "companyId": "1",
        "name": "税务管理部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398536969265152",
        "pid": "1175311325720936448",
        "companyId": "1",
        "name": "薪资管理部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398608847052800",
        "pid": "1175311373083017216",
        "companyId": "1",
        "name": "Java研发部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398661355544576",
        "pid": "1175311373083017216",
        "companyId": "1",
        "name": "Python研发部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398708763762688",
        "pid": "1175311373083017216",
        "companyId": "1",
        "name": "Php研发部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235398917619130368",
        "pid": "1175311466846683136",
        "companyId": "1",
        "name": "北京事业部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1235399011458293760",
        "pid": "1175311466846683136",
        "companyId": "1",
        "name": "上海事业部",
        "code": null,
        "managerId": null,
        "manager": null,
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1452086314642358272",
        "pid": "1175311325720936448",
        "companyId": "1",
        "name": "祈妹级驱逐舰海战部",
        "code": null,
        "managerId": null,
        "manager": "孙财",
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1452088255153881088",
        "pid": "1235399011458293760",
        "companyId": "1",
        "name": "社会化",
        "code": "1123123",
        "managerId": null,
        "manager": "小伙子不地道",
        "introduce": "撒打发",
        "createTime": null
    },
    {
        "id": "1452092499651117056",
        "pid": "1452088255153881088",
        "companyId": "1",
        "name": "123",
        "code": "456",
        "managerId": null,
        "manager": "瞿光明",
        "introduce": "456798",
        "createTime": null
    },
    {
        "id": "1452098775063904256",
        "pid": "1452098720512786432",
        "companyId": "1",
        "name": "123123",
        "code": null,
        "managerId": null,
        "manager": "凡是问问自己配不配",
        "introduce": null,
        "createTime": null
    },
    {
        "id": "1452098850662039552",
        "pid": "1452098720512786432",
        "companyId": "1",
        "name": "333333333",
        "code": null,
        "managerId": null,
        "manager": "凡是问问自己配不配",
        "introduce": null,
        "createTime": null,
    }
];


function dealData (data) {
    const newData = data.map(item => ({ ...item, children: [] }));

    for (const item of newData) {
        if (item.pid) {
            const parent = newData.find(pItem => pItem.id === item.pid);
            if (parent) {
                parent.children.push(item);
            }
        }
    }

    return newData.filter(item => !item.pid);

}

console.log(dealData(data));